find the inverse of a function